package com.naiterui.ehp.bp.support.security;

import org.springframework.util.PathMatcher;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * 拦截器信息封装类 用与拦截器注入，由{@link com.naiterui.ehp.bp.support.config.WebMvcAutoConfiguration}的addInterceptors()将公共拦截器、服务拦截器统一注入 其中公用拦截器执行顺讯优与服务拦截器
 *
 * @author mudou
 * @since 1.0.0
 */
public class InterceptorAddition {

    private HandlerInterceptor interceptor;

    /**
     * 拦截器匹配规则
     */
    private String[] excludePathPatterns;
    private PathMatcher pathMatcher;
    private String[] addPathPatterns;

    /**
     * 创建拦截器实例 InterceptorAddition.build()
     *
     * @param interceptor
     * @return
     * @Author mudou
     * @Date 2017年11月16日
     * @since 1.0.0
     */
    public static InterceptorAddition build(HandlerInterceptor interceptor) {
        InterceptorAddition addition = new InterceptorAddition();
        addition.interceptor = interceptor;
        return addition;
    }

    public InterceptorAddition excludePathPatterns(String... excludePathPatterns) {
        this.excludePathPatterns = excludePathPatterns;
        return this;
    }

    public InterceptorAddition pathMatcher(PathMatcher pathMatcher) {
        this.pathMatcher = pathMatcher;
        return this;
    }

    public InterceptorAddition addPathPatterns(String... addPathPatterns) {
        this.addPathPatterns = addPathPatterns;
        return this;
    }

    // ========================================

    public HandlerInterceptor getInterceptor() {
        return this.interceptor;
    }

    public String[] getExcludePathPatterns() {
        return this.excludePathPatterns;
    }

    public PathMatcher getPathMatcher() {
        return this.pathMatcher;
    }

    public String[] getAddPathPatterns() {
        return this.addPathPatterns;
    }
    // ========================================
}
